<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/base/jsp/include.jsp"%>
<style>
</style>
<script type="text/javascript">
	var id = "${id}";
	var editor;
	var submitForm = function($dialog, $grid, $pjq, $mainMenu) {
		if ($('form').form('validate')) {
			var url = sy.contextPath + '/shareItem/save';
			var obj = sy.serializeObject($('form'));
			var img = $('#file_upload').getFileId();
			obj.img = img;
			obj.detail = editor.getHtml();
			$.post(url,obj , function(result) {
				if (result.code == 0) {
					$grid.datagrid('reload');
					$dialog.dialog('destroy');
					$mainMenu.tree('reload');
				} else {
					$pjq.messager.alert('提示', '操作失败', 'error');
				}
			}, 'json');
		}
	};

	$(function() {
		editor = new HtmlEditor('#content');
		if (id != '') {
			$.post(sy.contextPath + '/shareItem/findById', {
				id : id
			}, function(result) {
				if (result) {
					$('form').form('load', result);
					$('#file_upload').setFileId(result.img,false,true,true,"640x320");
					$('#time').datetimebox('setValue',result.endTime);
					editor.setHtml(result.detail);
				}
			}, 'json');
		}
	});
</script>
</head>
<body>
	<form id="form" method="post">
        <input name="id" type="hidden" />
        <div style="padding:15px;font-size: 12px">
            <table style="table-layout:fixed;" border="0" cellspacing="0" class="formtable">
            	<tr>
                    <th style="width:100px;">名称：</th>
                    <td>
                    	 <input id="title" name="name" class="easyui-textbox" data-options="required:true,validType:['length[0,25]']" missingMessage="请输入名称" style="width: 90%;" prompt="请输入名称"/>
                    </td>
                </tr>
                <tr>
                    <th style="width:100px;">简介：</th>
                    <td>   
                    	 <input id="info" name="info" class="easyui-textbox" data-options="required:true,validType:['length[0,50]']" prompt="请输入简介" missingMessage="请输入简介" style="width: 90%;"/>
                    </td>
                </tr>
                <tr>
                    <th style="width:100px;">结束时间：</th>
                    <td>   
                    	 <input id="time" name="end" class="easyui-datetimebox" data-options="required:true,showSeconds:false" prompt="请选择结束时间" missingMessage="请选择结束时间" style="width: 200px;"/>
                    </td>
                </tr>
                <tr>
                    <th style="width:100px;">图片：</th>
                    <td ><input id="file_upload" multi="false"
						type="file" showBtn="true" showImage="true" fileType="*.jpg;*.png"
						fileSize="200KB" buttonText="上传图片" /></td>
                </tr>
                <tr>
                	<th>详情:</th>
                	<td>
				  		<textarea id="content" style="width:98%;height: 400px"></textarea>
				  	</td>
                </tr>
            </table>
        </div>
	</form>
</body>
</html>